package com.amado.course13.zuoye;

public class StudentManagerDemo {

	public static void main(String[] args) {
		//以前的方式
		String[][] studentArray = initStudent();
		
		// 教师
		StudentTeacherRelation[] relationArray = initRelation();
		
	}

	public static String[][] initStudent() {
		String[][] studentArray = new String[100][3];
		studentArray[0] = new String[]{"1","2","3"};
		studentArray[1] = new String[]{"1","2","3"};
		return studentArray;
	}
	
	public static StudentTeacherRelation[] initRelation() {
		StudentTeacherRelation[] relationArray =  new StudentTeacherRelation[100];
		//student是一个变量
		StudentTeacherRelation student = new StudentTeacherRelation();
		//teacherNum是属性
		student.teacherNum = "JX001";
		student.studentNum = "XY001";

		StudentTeacherRelation student2 = new StudentTeacherRelation();
		student.teacherNum = "JX002";
		student.studentNum = "XY001";

		relationArray[0] = student;
		relationArray[1] = student2;
		return relationArray;
	}
	public static void print(StudentTeacherRelation[] relations) {
		for(StudentTeacherRelation relation:relations) {
			System.out.println(relation.studentNum+" "+relation.teacherNum);
		}
	}
	public static void print(String[][] relations) {
		for(String[] relation:relations) {
			for(String temp:relation) {
				System.out.print(temp+"\t");
			}
		}
	}
	public static boolean isExist(String[][] studentArray,String studentNum) {
		for(String[] tempArray:studentArray){
			if(tempArray[1].equals(studentNum)){
				return true;
			}
		}
		return false;
	}
	public static String[] getStudent(String[][] studentArray,String studentNum) {
		for(String[] tempArray:studentArray){
			if(tempArray[1].equals(studentNum)){
				return tempArray;
			}
		}
		return null;
	}


	/**
	 * 判断是否存在关联关系
	 * 
	 * @param relationArray
	 *            教师与学员关联关系
	 * @param teacherNum
	 *            教师
	 * @param studentNum
	 * @return
	 */
	public static boolean isExistBandRelation(StudentTeacherRelation[] relationArray, String teacherNum,
			String studentNum) {
		for (StudentTeacherRelation relation : relationArray) {
			// XY001,JS001
			if (relation.studentNum.equals(studentNum) && relation.teacherNum.equals(teacherNum)) {
				return true;
			}
		}
		return false;
	}

}
